/** A class representing a route between two cities.
    A route contains information relevant to such a route, including
    the number of the route, the distance the route is, and the relative
    travel time it takes to traverse the route (so, for example, a short
    route which is always backed up can be weighed more heavily than a
    slightly longer route which is usually clear). <br>
    
    This class is intended to be used as a type parameter for link information
    in a city graph - routes link cities together.
    @author Ian Helmke, Dan King **/
public class Route {
  /** The name/number of this route on a map (for example, I293 or US101) **/
  private String name;
  /** The distance of this route between the two cities it links. **/
  private double distance;
  /** The relative travel time of this route. A route with heavier traffic should
      have a higher value here. **/
  private double routeWeight;

  /** The default constructor.
      @param name The name of this route on a map. For example, I293 or US101.
      @param distance The distance between the two cities linked by this route.
      @param routeWeight The relative travel time of this route. A route with heavier
             traffic should have a higher value and vise versa. This is used
             in the getWeightedDistance method to determine the weighted value of this
             route. A value of 1 means that this route is unweighted.
  */
  public Route(String name, double distance, double routeWeight) {
    this.name = name;
    this.distance = distance;
    this.routeWeight = routeWeight;
  }

  /** An alternate constructor for a route. In this version, the distance is calculated
      automatically based on the given two cities.
      @param name The name of this route on a map. For example, I293 or US101.
      @param routeWeight The relative travel time of this route. A route with heavier
             traffic should have a higher value and vise versa. This is used
             in the getWeightedDistance method to determine the weighted value of this
             route. A value of 1 means that this route is unweighted.
      @param origin The city this route comes from.
      @param destination The destination city of this route.
  */
  public Route(String name, double routeWeight, City origin, City destination) {
    this.name = name;
    this.distance = Math.sqrt(((origin.getPosition().x - destination.getPosition().x) *
                               (origin.getPosition().x - destination.getPosition().x)) + 
                               ((origin.getPosition().y - destination.getPosition().y) *
                                (origin.getPosition().y - destination.getPosition().y))) *
      Math.sqrt((68 * 68) + (58 * 58)) / 2;
    this.routeWeight = routeWeight;
  }
  /** Determines the weighted disance for this route based on the weight of the
      route and the distance. This property is intended to allow a program to
      take into account traffic or other factors that may make a route take longer
      to traverse than its distance alone would indicate.
      @return The weighted distance of this route.
  */
  public double getWeightedDistance() {
    return routeWeight * distance;
  }

  /** Gets the relative weight of this route, independent of the distance the
      route spans.
      @return The relative weight of this route.
  */ 
  public double getRouteWeight() {
    return this.routeWeight;
  }

}
